#ifndef WORLD_H
#define WORLD_H

#include "Singleton.h"
#include "Vec2.h"
#include <vector>
#include "Obstacle.h"

typedef std::vector <std::vector <bool>> CellGrid;

class World : public Engine::NonCopyable
{
	private:
		friend class Engine::Singleton <World>;
		World();

		CellGrid m_cellGrid;
		Engine::Vec2 m_offset, m_cellDims;

		typedef std::vector <Obstacle*> ObstacleVec;
		ObstacleVec m_obstacleVec;

	public:
		void CreateRandom(unsigned int width, unsigned int height,
						  float cellWidth, float cellHeight,
						  unsigned int percentageOfObstacles);

		bool IsBoundary(unsigned int x, unsigned int y);
		bool IsPassable(unsigned int x, unsigned int y);

		unsigned int GetWorldWidth() const {return m_cellGrid.size();}
		unsigned int GetWorldHeight() const {return m_cellGrid[0].size();}
		float GetCellWidth() const {return m_cellDims.x;}
		float GetCellHeight() const {return m_cellDims.y;}
		CellGrid GetCellGrid() const {return m_cellGrid;}
		const Engine::Vec2& GetOffset() const {return m_offset;}
		void Draw();

		~World();
};

typedef Engine::Singleton <World> TheWorld;

#endif
